<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html lang="en">
<head>
<base href="<%=basePath%>">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
	<link rel="stylesheet"
	href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="${pageContext.request.contextPath}/js/jqueryui.js"></script>
<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<title>团购后台管理系统</title>

<script>
	$(function() {
	$("#startDate").datepicker();
		$("#startDate").datepicker("option","dateFormat","yy-mm-dd");
	})
</script>
<style>
.main_div {
	min-width: 1000px;
}
.pageChange {
	float: right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div" style="height:40px">
					<div class="main_title">
						<span>秒杀广告管理</span>
					</div>
					<input style="display:none" value="5" id="pageCount"
						name="pageCount" />
				</div>

				<div class="force-overflow1-1">
					<table id="showtable"
						class="table table-condensed table-bordered table-hover"
						style="text-align: center">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">序号</th>
							<th style="text-align: center">商品缩略图</th>
							<th style="text-align: center">秒杀广告</th>
							<th style="text-align: center">商品名称</th>
							<th style="text-align: center">商品原价</th>
							<th style="text-align: center">秒杀价格</th>
							<th style="text-align: center">商品数量</th>
							<th style="text-align: center">开始日期</th>
							<th style="text-align: center">开始时间</th>
							<th style="text-align: center">结束时间</th>
							<th style="text-align: center">详情</th>
							<th style="text-align: center">申请审核</th>
						</tr>
					</table>
					<div class="pageChange" style="margin-bottom:30px">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button class="btn btn-primary" onclick="searchPage()">搜索</button>
					</div>
				</div>
			</div>
		</section>
		<script>
			$(function() {
				selectinfo();
			})
			
		
			function selectinfo() {
				var pageNum = $("#pageNum").html();
				var pageCount = $("#pageCount").val();				
				$.post(urls + "seckillAction/selectSeckillProductList",
					{
					    typeId:0,
						pageNum : pageNum,
						pageCount : pageCount,
						otherId:localStorage.getItem("otherid"),
						status:-4
					},
					function(data) {
					    console.log(data)
						if (data) {
							var totalpage = data.totalpage;
							var orderlist = data.list;
							var table = $("#showtable");
							$("tr").remove(".addtr");
							for (var i = 0; i < orderlist.length; i++) {
							    var status;
							    if(orderlist[i].status==1){
							      status="<input onclick='applySure(\"" + orderlist[i].id +"|$"+orderlist[i].productName+"|$"+orderlist[i].adPrice+ "\")' type='button' class='btn btn-primary' value='发布' />"
							    }else if(orderlist[i].status==3){
							       status="已发布"
							    }else if(orderlist[i].status==4){
							      status="已过期"
							    }
								var append = "<tr id='" + orderlist[i].id + "'  class='addtr'><td style='line-height:120px'>" + (i + 1) + "</td>" +
									"<td ><img style='width:250px;height:120px' src='/seckills/" + orderlist[i].productImg + "' alt='加载中'/> </td>" +
									"<td ><img style='width:250px;height:120px' src='/seckills/" + orderlist[i].publicityImg + "' alt='加载中'/> </td>" +
									"<td style='line-height:120px'>" + orderlist[i].productName + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].productPrice + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].seckillPrice + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].inventory + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].startDate + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].startTime + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].endTime + "</td>" +
									"<td style='vertical-align:middle;'>" + orderlist[i].details + "</td>" +
									"<td style='line-height:120px'>"+status+"</td></tr>";
								table.append(append);
							}
							$("#totalpage").html(totalpage);
						}
					}
					, "json"
				)
			}
        function applySure(e){
        var arr1=e.split("|$")[0];
         var arr2=e.split("|$")[1];
          var arr3=e.split("|$")[2]
        location.href="${pageContext.request.contextPath}/YMGback/other/wechatPay.jsp?id="+arr1+"&name="+arr2+"&adprice="+arr3; 
          /*$.post(urls + "otherAction/applyCheckSeckillProduct",{
            status:1,
            id:e
         },function(res){
         console.log(res)
           if(res==true){
           alert("申请成功")
           selectinfo()
           }else{
           alert("申请失败")
           }
         }) */
        }
		</script>		
	</div>
	<script>
		
	</script>
</body>
</html>
